<?php

class GalleryImage {
	private $ID;
	private $ImageDisplayName;
	private $ImageFileName;
	private $ImageThumbnail;
	private $ImageComment = "";
	private $AlbumID;

	private $Controller;

	function __construct($image_id, $Controller){
		$this->Controller = $Controller;

		$MySQL = $this->Controller->UseApps["mysql"];

		$Sql = $MySQL->generateSelectQuery($MySQL->getPrefix()."lightbox_images", array("id" => $image_id));
		
		$QueryImage = $MySQL->query($Sql);
		
		if(mysql_num_rows($QueryImage) <= 0){
			return false;
		}
		
		$Fetch = mysql_fetch_assoc($QueryImage);
		
		$this->ID = $Fetch["id"];
		$this->ImageDisplayName = $Fetch["image_name"];
		$this->ImageFileName = $Fetch["image_file_name"];
		$this->ImageThumbnail = $Fetch["image_thumbnail"];
		$this->ImageComment = $Fetch["image_comment"];
		$this->AlbumID = $Fetch["album_id"];
	}
	
	function getID(){
		return $this->ID;
	}
	
	function getDisplayName(){
		return $this->ImageDisplayName;
	}
	
	function getFileName(){
		return $this->ImageFileName;
	}
	
	function getImageComment(){
		return $this->ImageComment;
	}
	
	function getAlbumID(){
		return $this->AlbumID;
	}
	
	function getAlbumName(){
		$MySQL = $this->Controller->UseApps["mysql"];
		$Result = $MySQL->query("SELECT * FROM {$MySQL->getPrefix()}lightbox_albums WHERE id = $this->AlbumID");
		
		if(mysql_num_rows($Result) <= 0){
			return false;
		}
		
		$Fetch = mysql_fetch_assoc($Result);
		
		return $Fetch["album_name"];
	}
		
	function getImagePath(){
		$URL = Core::$FMSConfig->getValue("environment", "url");
	
		return $URL."content/lbgallery/".$this->getAlbumName()."/".$this->ImageFileName;
	}
	
	function getThumbnailPath(){
		$URL = Core::$FMSConfig->getValue("environment", "url");
		
		return $URL."content/lbgallery/".$this->getAlbumName()."/".$this->ImageThumbnail;
	}

}

?>